package com.cloud.lan.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cloud.lan.entity.model.dataobject.LanUserPraiseDO;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 用户点赞表 Mapper 接口
 * </p>
 *
 * @author xyqierkang@163.com
 * @since 2022-05-21
 */
@Mapper
public interface LanUserPraiseMapper extends BaseMapper<LanUserPraiseDO> {

    @Select("select count(*) from lan_user_praise p\n" +
            "         left join lan_goods_evaluate lge on p.evaluate_id = lge.id\n" +
            "where p.cancel = 0\n" +
            "  and p.evaluate_id = #{evaluateId}")
    Integer getPraiseCount(@Param("evaluateId") long evaluateId);

    @Select("select count(*) from lan_user_praise p\n" +
            "         left join lan_goods_evaluate lge on p.evaluate_id = lge.id\n" +
            "where p.cancel = 0\n" +
            "  and p.evaluate_id = #{evaluateId} and p.user_id = #{userId}")
    Integer getOneselfCount(@Param("evaluateId") long evaluateId, @Param("userId") long userId);
}
